package com.xiyu.service.repository.customer.pool;

import com.xiyu.service.model.customer.pool.CustomerPoolRulePost;
import com.xiyu.service.model.customer.pool.CustomerPoolRulePostTable;
import org.babyfish.jimmer.spring.repository.JRepository;

import java.util.List;

public interface CustomerPoolRulePostRepository extends JRepository<CustomerPoolRulePost, Long> {
    CustomerPoolRulePostTable customerPoolRulePostTable = CustomerPoolRulePostTable.$;

    default void deleteByRuleAndPost(Long ruleId, List<Long> postIds){
        sql().createDelete(customerPoolRulePostTable)
                .where(customerPoolRulePostTable.ruleId().eq(ruleId))
                .whereIf(postIds != null, () -> customerPoolRulePostTable.postId().notIn(postIds))
                .execute();
    }

}